module cl {
	export class MoveRemainEffect {

		public static play(troopGroup : eui.Group, moveRemainRatio : number) : void {
			let troopImage = troopGroup.getChildAt(1);
			let color = (troopImage.filters == undefined || troopImage.filters.length < 1)
							? 1.0
							: (troopImage.filters[0] as egret.ColorMatrixFilter).matrix[0];

			let level = Math.floor(1.5 - moveRemainRatio);
			if (level < 0) {
				level = 0;
			}
			let toColor = 1.0 - 0.25 * level;
			if (Math.abs(color - toColor) < 0.05){
				return;
			}

			let handle = setInterval(() => {
				if (Math.abs(color - toColor) < 0.05) {
					clearInterval(handle);
					return;
				}
				let step = toColor > color ? 0.05 : -0.05;
				color += step;
				Util.setColor(troopImage, color, color, color);
			}, 100);
		}
	}
}